<template>
	<view>
		<view class="title">{{msg.title}}</view>
		<view class="content" v-html="msg.content"> </view>
		<view class="time" style="text-align: end;">{{time}}</view>
	</view>
</template>

<script>
	import {
		getInformationDetails
	} from "../../api/index.js"
	export default {
		data() {
			return {
				msg: {},
				time: '',
			}
		},
		async onLoad(opt) {
			await this.onGetInformationDetails(opt.id)
			this.time = opt.time
		},
		methods: {
			async onGetInformationDetails(id) {
				const res = await getInformationDetails(`s=/ApiZwyRequest/messagedetail&id=${id}`)
				const {
					data,
					status,
					msg
				} = res.data
				if (status == 1) {
					this.msg = data
					await this.onGetMsgCount()
					console.log(data, "res----")
				} else {
					this.showToast(msg)
				}
			},
			// 宣传轮播
			async onGetMsgCount() {
				const res = await getInformationDetails(`s=ApiZwyRequest/getmsgcount`)
				const {
					msgcount,
					status,
					msg
				} = res.data
				console.log(res)
				if (status == 1) {
					if (msgcount > 0) {
						uni.setTabBarBadge({
							index: 2,
							text: msgcount > 99 ? '99+' : `${msgcount}`
						})
					} else {
						uni.removeTabBarBadge({
							index: 2
						})
					}
				} else {
					this.showToast(msg)
				}
			},

		}
	}
</script>

<style lang="scss" scoped>
	.time {
		color: #999;
		padding: 100rpx 30rpx 0;
	}

	.title {
		color: #222222;
		margin-bottom: 30rpx;
		font-size: 32rpx;
		text-align: center;

	}

	.content {
		padding: 30rpx;
	}
</style>